package com.huanuo.internetofthings.service.role;

import com.google.common.collect.Lists;
import com.huanuo.internetofthings.bo.role.Role;
import com.huanuo.internetofthings.dao.role.RoleMapper;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.unicorn.framework.base.base.AbstractService;
import org.unicorn.framework.core.SysCode;
import org.unicorn.framework.core.exception.PendingException;

@Service
public class RoleService extends AbstractService {

	@Autowired
	private RoleMapper roleMapper;

	public List<Role> selectRoleListByIds(List<Integer> roleIds) throws PendingException {
		try {
			if (CollectionUtils.isEmpty(roleIds)) {
				return Lists.newArrayList();
			}
			return this.roleMapper.selectListByIds(roleIds);
		} catch (Exception e) {
			error("查询用户拥有的角色", e);
			throw new PendingException(SysCode.DB_ERROR, "查询用户拥有的角色");
		}
		
	}
}